using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class AddToCart : System.Web.UI.Page
{
    private Invoice _selectedInvoice = new Invoice();
    public Invoice SelectedInvoice
    {
        get
        {
            if (_selectedInvoice.InvoiceId == "")
            {
                try
                {
                    _selectedInvoice = (Invoice)Session["Invoice"];
                }
                catch { }
            }
            return _selectedInvoice;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        int qty = 1; //default is 1 unless pass in another value

        if (Request["qty"] != null)
        {
            qty = int.Parse(Request["qty"].ToString());
        }
        if (Request["ProductId"] != null)
        {
            SelectedInvoice.AddToInvoice(int.Parse(Request["ProductId"].ToString()), qty);
        }
        Response.Redirect("ViewCart.aspx");
    }
}
